package routes

import (
	"gin/controller/user"
	"gin/middleware"

	"github.com/gin-gonic/gin"
)

func UserRoute(c *gin.Engine) {
	user_c := user.User{}
	role_c := user.Role{}
	permission_c := user.Permission_c{}
	c.GET("/", middleware.GlobalMiddleware, user_c.Table)
	//用户分组
	login := c.Group("login")
	{
		//首页
		login.GET("/index", user_c.Index)
		//用户登录页面路由
		login.GET("/userLoginFrom", user_c.UserLoginFrom)
		//用户登录数据请求路由
		login.POST("/userLoginData", user_c.UserLoginData)
		//退出登录
		login.GET("/userOutLogin", user_c.LoginOut)
	}
	//后台用户管理
	backendUsers := c.Group("/backendUsers/")
	{
		//账号管理
		accoun := backendUsers.Group("account/")
		{
			//账号列表
			accoun.GET("list", user_c.UserList)
			accoun.POST("add", user_c.UserAdd)
			accoun.POST("del", user_c.UserDel)
			accoun.POST("upd", user_c.UserUpd)

		}
		//角色管理
		role := backendUsers.Group("role")
		{
			//账号列表
			role.GET("list", role_c.RoleList)
			role.POST("add", role_c.RoleAdd)
			role.POST("del", role_c.RoleDel)
			role.POST("upd", role_c.RoleUpd)
		}
		//权限管理
		permission := backendUsers.Group("permission")
		{
			//账号列表
			permission.GET("list", permission_c.PermissionList)
			permission.POST("add", permission_c.PermissionAdd)
			//permission.POST("del", permission_c.RoleDel)
			//permission.POST("upd", permission_c.RoleUpd)
		}

	}
}
